package com.jcl.elasticsearch.mapper.provider;

import com.jcl.elasticsearch.resume.model.SearchResume;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

public class SearchResumeSqlProvider {

    public String insertSelective(SearchResume record) {
        BEGIN();
        INSERT_INTO("search_resume");

        if (record.getRealname() != null) {
            VALUES("realname", "#{realname,jdbcType=VARCHAR}");
        }

        if (record.getSex() != null) {
            VALUES("sex", "#{sex,jdbcType=VARCHAR}");
        }

        if (record.getMobile() != null) {
            VALUES("mobile", "#{mobile,jdbcType=VARCHAR}");
        }

        if (record.getEmail() != null) {
            VALUES("email", "#{email,jdbcType=VARCHAR}");
        }

        if (record.getBirthday() != null) {
            VALUES("birthday", "#{birthday,jdbcType=DATE}");
        }

        if (record.getNativePlace() != null) {
            VALUES("native_place", "#{nativePlace,jdbcType=VARCHAR}");
        }

        if (record.getCurrentCity() != null) {
            VALUES("current_city", "#{currentCity,jdbcType=VARCHAR}");
        }

        if (record.getCurrentAddress() != null) {
            VALUES("current_address", "#{currentAddress,jdbcType=VARCHAR}");
        }

        if (record.getEvaluate() != null) {
            VALUES("evaluate", "#{evaluate,jdbcType=VARCHAR}");
        }

        if (record.getCurrentSalary() != null) {
            VALUES("current_salary", "#{currentSalary,jdbcType=VARCHAR}");
        }

        if (record.getDesireSalaryStart() != null) {
            VALUES("desire_salary_start", "#{desireSalaryStart,jdbcType=INTEGER}");
        }

        if (record.getDesireSalaryEnd() != null) {
            VALUES("desire_salary_end", "#{desireSalaryEnd,jdbcType=INTEGER}");
        }

        if (record.getWorkyear() != null) {
            VALUES("workyear", "#{workyear,jdbcType=INTEGER}");
        }

        if (record.getWorkIndustry() != null) {
            VALUES("work_industry", "#{workIndustry,jdbcType=VARCHAR}");
        }

        if (record.getWorkLastPosition() != null) {
            VALUES("work_last_position", "#{workLastPosition,jdbcType=VARCHAR}");
        }

        if (record.getWorkLastCompany() != null) {
            VALUES("work_last_company", "#{workLastCompany,jdbcType=VARCHAR}");
        }

        if (record.getWorkDetail() != null) {
            VALUES("work_detail", "#{workDetail,jdbcType=VARCHAR}");
        }

        if (record.getEduLastEducation() != null) {
            VALUES("edu_last_education", "#{eduLastEducation,jdbcType=VARCHAR}");
        }

        if (record.getEduLastSchool() != null) {
            VALUES("edu_last_school", "#{eduLastSchool,jdbcType=VARCHAR}");
        }

        if (record.getEduLastSchoolTag() != null) {
            VALUES("edu_last_school_tag", "#{eduLastSchoolTag,jdbcType=VARCHAR}");
        }

        if (record.getEduLastSchoolRank() != null) {
            VALUES("edu_last_school_rank", "#{eduLastSchoolRank,jdbcType=INTEGER}");
        }

        if (record.getEduLastMajor() != null) {
            VALUES("edu_last_major", "#{eduLastMajor,jdbcType=VARCHAR}");
        }

        if (record.getSource() != null) {
            VALUES("source", "#{source,jdbcType=INTEGER}");
        }

        if (record.getEduDetail() != null) {
            VALUES("edu_detail", "#{eduDetail,jdbcType=VARCHAR}");
        }

        if (record.getProjectDetail() != null) {
            VALUES("project_detail", "#{projectDetail,jdbcType=VARCHAR}");
        }

        if (record.getSourceSub() != null) {
            VALUES("source_sub", "#{sourceSub,jdbcType=VARCHAR}");
        }

        if (record.getApplyStatus() != null) {
            VALUES("apply_status", "#{applyStatus,jdbcType=INTEGER}");
        }

        if (record.getApplyDepartment() != null) {
            VALUES("apply_department", "#{applyDepartment,jdbcType=VARCHAR}");
        }

        if (record.getApplyPosition() != null) {
            VALUES("apply_position", "#{applyPosition,jdbcType=VARCHAR}");
        }

        if (record.getApplyDate() != null) {
            VALUES("apply_date", "#{applyDate,jdbcType=DATE}");
        }

        if (record.getUpdateDate() != null) {
            VALUES("update_date", "#{updateDate,jdbcType=DATE}");
        }

        if (record.getApplyOtherJid() != null) {
            VALUES("apply_other_jid", "#{applyOtherJid,jdbcType=VARCHAR}");
        }

        if (record.getArrivalInfo() != null) {
            VALUES("arrival_info", "#{arrivalInfo,jdbcType=VARCHAR}");
        }

        if (record.getStatus() != null) {
            VALUES("status", "#{status,jdbcType=INTEGER}");
        }

        if (record.getCreatetime() != null) {
            VALUES("createtime", "#{createtime,jdbcType=TIMESTAMP}");
        }

        if (record.getTags() != null) {
            VALUES("tags", "#{tags,jdbcType=VARCHAR}");
        }

        if (record.getKeyword() != null) {
            VALUES("keyword", "#{keyword,jdbcType=VARCHAR}");
        }

        return SQL();
    }

    public String updateByPrimaryKeySelective(SearchResume record) {
        BEGIN();
        UPDATE("search_resume");

        if (record.getRealname() != null) {
            SET("realname = #{realname,jdbcType=VARCHAR}");
        }

        if (record.getSex() != null) {
            SET("sex = #{sex,jdbcType=VARCHAR}");
        }

        if (record.getMobile() != null) {
            SET("mobile = #{mobile,jdbcType=VARCHAR}");
        }

        if (record.getEmail() != null) {
            SET("email = #{email,jdbcType=VARCHAR}");
        }

        if (record.getBirthday() != null) {
            SET("birthday = #{birthday,jdbcType=DATE}");
        }

        if (record.getNativePlace() != null) {
            SET("native_place = #{nativePlace,jdbcType=VARCHAR}");
        }

        if (record.getCurrentCity() != null) {
            SET("current_city = #{currentCity,jdbcType=VARCHAR}");
        }

        if (record.getCurrentAddress() != null) {
            SET("current_address = #{currentAddress,jdbcType=VARCHAR}");
        }

        if (record.getEvaluate() != null) {
            SET("evaluate = #{evaluate,jdbcType=VARCHAR}");
        }

        if (record.getCurrentSalary() != null) {
            SET("current_salary = #{currentSalary,jdbcType=VARCHAR}");
        }

        if (record.getDesireSalaryStart() != null) {
            SET("desire_salary_start = #{desireSalaryStart,jdbcType=INTEGER}");
        }

        if (record.getDesireSalaryEnd() != null) {
            SET("desire_salary_end = #{desireSalaryEnd,jdbcType=INTEGER}");
        }

        if (record.getWorkyear() != null) {
            SET("workyear = #{workyear,jdbcType=INTEGER}");
        }

        if (record.getWorkIndustry() != null) {
            SET("work_industry = #{workIndustry,jdbcType=VARCHAR}");
        }

        if (record.getWorkLastPosition() != null) {
            SET("work_last_position = #{workLastPosition,jdbcType=VARCHAR}");
        }

        if (record.getWorkLastCompany() != null) {
            SET("work_last_company = #{workLastCompany,jdbcType=VARCHAR}");
        }

        if (record.getWorkDetail() != null) {
            SET("work_detail = #{workDetail,jdbcType=VARCHAR}");
        }

        if (record.getEduLastEducation() != null) {
            SET("edu_last_education = #{eduLastEducation,jdbcType=VARCHAR}");
        }

        if (record.getEduLastSchool() != null) {
            SET("edu_last_school = #{eduLastSchool,jdbcType=VARCHAR}");
        }

        if (record.getEduLastSchoolTag() != null) {
            SET("edu_last_school_tag = #{eduLastSchoolTag,jdbcType=VARCHAR}");
        }

        if (record.getEduLastSchoolRank() != null) {
            SET("edu_last_school_rank = #{eduLastSchoolRank,jdbcType=INTEGER}");
        }

        if (record.getEduLastMajor() != null) {
            SET("edu_last_major = #{eduLastMajor,jdbcType=VARCHAR}");
        }

        if (record.getSource() != null) {
            SET("source = #{source,jdbcType=INTEGER}");
        }

        if (record.getEduDetail() != null) {
            SET("edu_detail = #{eduDetail,jdbcType=VARCHAR}");
        }

        if (record.getProjectDetail() != null) {
            SET("project_detail = #{projectDetail,jdbcType=VARCHAR}");
        }

        if (record.getSourceSub() != null) {
            SET("source_sub = #{sourceSub,jdbcType=VARCHAR}");
        }

        if (record.getApplyStatus() != null) {
            SET("apply_status = #{applyStatus,jdbcType=INTEGER}");
        }

        if (record.getApplyDepartment() != null) {
            SET("apply_department = #{applyDepartment,jdbcType=VARCHAR}");
        }

        if (record.getApplyPosition() != null) {
            SET("apply_position = #{applyPosition,jdbcType=VARCHAR}");
        }

        if (record.getApplyDate() != null) {
            SET("apply_date = #{applyDate,jdbcType=DATE}");
        }

        if (record.getUpdateDate() != null) {
            SET("update_date = #{updateDate,jdbcType=DATE}");
        }

        if (record.getApplyOtherJid() != null) {
            SET("apply_other_jid = #{applyOtherJid,jdbcType=VARCHAR}");
        }

        if (record.getArrivalInfo() != null) {
            SET("arrival_info = #{arrivalInfo,jdbcType=VARCHAR}");
        }

        if (record.getStatus() != null) {
            SET("status = #{status,jdbcType=INTEGER}");
        }

        if (record.getCreatetime() != null) {
            SET("createtime = #{createtime,jdbcType=TIMESTAMP}");
        }

        if (record.getTags() != null) {
            SET("tags = #{tags,jdbcType=VARCHAR}");
        }

        if (record.getKeyword() != null) {
            SET("keyword = #{keyword,jdbcType=VARCHAR}");
        }

        WHERE("id = #{id,jdbcType=INTEGER}");

        return SQL();
    }
}